Cleanup most of the no-brainer warnings hocked up by clang.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 23 Mar 2013 22:52:12 +0000 (22:52 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 23 Mar 2013 22:52:12 +0000 (22:52 +0000)
14 files changed:
gpsbabel/cst.cc
gpsbabel/delbin.cc
gpsbabel/garmin_tables.cc
gpsbabel/gbfile.cc
gpsbabel/gpx.cc
gpsbabel/kml.cc
gpsbabel/pdbfile.cc
gpsbabel/pdbfile.h
gpsbabel/pocketfms_wp.cc
gpsbabel/skytraq.cc
gpsbabel/smplrout.cc
gpsbabel/text.cc
gpsbabel/vecs.cc
gpsbabel/xhtmlent.cc

index 7bdc32bbbf06f3caed16a9cf8f632c036dc5e956..aca0cac02704904c3f0172d618130b98ba22eb33 100644 (file)
@@ -231,7 +231,7 @@ cst_data_read(void)
           if (strcmp(cin + 2, "note") == 0) {
             buff = gbfgetstr(fin);
             if (buff == NULL) {
-              buff = "";
+              buff = (char *) "";
             }
             line++;
             cin = lrtrim(buff);
index 41d2b9355b2aa9330a12b2695fef1e7ece62709b..51635ae4db6ed59ede3d10a6f26cacc0b6aee0cf 100644 (file)
@@ -134,7 +134,7 @@ static arglist_t delbin_args[] = {
     ARG_NOMINMAX
   },
   {"hint_at_end", &opt_hint_at_end, "If true, geocache hint at end of text", NULL, ARGTYPE_BOOL, ARG_NOMINMAX },
-  {"gcsym", &opt_gcsym, "If set to 0, prefer user-provided symbols over Groundspeaks ones for geocaches", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, "1" },
+  {"gcsym", &opt_gcsym, "If set to 0, prefer user-provided symbols over Groundspeaks ones for geocaches", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, (char *) "1" },
   ARG_TERMINATOR
 };
 
index 2af5b706304775b7203e2ade3e3bc7f3b9e20c4e..366f3f9ed1f0907bf4d52d26f160fda8d16f2a9e 100644 (file)
@@ -1039,7 +1039,7 @@ gt_lookup_datum_index(const char* datum_str, const char* module)
 gbuint32
 gt_color_value(const unsigned int garmin_index)
 {
-  if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
+  if ((garmin_index < GT_COLORS_CT)) {
     return gt_colors[garmin_index].rgb;
   } else {
     return unknown_color;  /* -1 */
@@ -1088,7 +1088,7 @@ gt_color_index_by_rgb(const int rgb)
 const char*
 gt_color_name(const unsigned int garmin_index)
 {
-  if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
+  if ((garmin_index < GT_COLORS_CT)) {
     return gt_colors[garmin_index].name;
   } else {
     return gt_colors[0].name;
index 1a6e86a439bca789c0de434f051fde04a99cbd12..854e86005b999e208d710b2d27032bd5a1d5ce45 100644 (file)
@@ -74,7 +74,7 @@ gzapi_open(gbfile* self, const char* mode)
 
   strcpy(openmode, mode);
   if (strchr(mode, 'b') == NULL) {
-    strncat(openmode, "b", sizeof(openmode));
+    strncat(openmode, "b", sizeof(openmode) - strlen(openmode) - 1);
   }
 
   if (self->is_pipe) {
index 510900ecc5aa003576e76c5940f1a32c21a9ab91..ee70640f38853e43bcfe52346ab726b1992a5f50 100644 (file)
@@ -1384,72 +1384,11 @@ gpx_read(void)
   int done = 0;
   char* buf = (char*) xmalloc(MY_CBUF_SZ);
   int result = 0;
-  int extra;
 
   while (!done) {
     if (fd) {
-      /*
-       * The majority of this block (in fact, all but the
-       * call to XML_Parse) are a disgusting hack to
-       * correct defective GPX files that Geocaching.com
-       * issues as pocket queries.   They contain escape
-       * characters as entities (&#x00-&#x1f) which makes
-       * them not validate which croaks expat and torments
-       * users.
-       *
-       * Look for '&' in the last maxentlength chars.   If
-       * we find it, strip it, then read byte-at-a-time
-       * until we find a non-entity.
-       */
-      char* badchar;
-      char* semi;
-      int maxentlength = 8;
-      len = gbfread(buf, 1, MY_CBUF_SZ - maxentlength, fd);
+      len = gbfread(buf, 1, MY_CBUF_SZ - 1, fd);
       done = gbfeof(fd) || !len;
-      buf[len] = '\0';
-      if (len < maxentlength) {
-        maxentlength = len;
-      }
-      badchar = buf+len-maxentlength;
-      badchar = strchr(badchar, '&');
-      extra = maxentlength - 1; /* for terminator */
-      while (badchar && len < MY_CBUF_SZ-1) {
-        semi = strchr(badchar, ';');
-        while (extra && !semi) {
-          len += gbfread(buf+len, 1, 1, fd);
-          buf[len]='\0';
-          extra--;
-          if (buf[len-1] == ';') {
-            semi= buf+len-1;
-          }
-        }
-        badchar = strchr(badchar+1, '&');
-      }
-      {
-        char hex[]="0123456789abcdef";
-        badchar = strstr(buf, "&#x");
-        while (badchar) {
-          int val = 0;
-          char* hexit = badchar+3;
-          semi = strchr(badchar, ';');
-          if (semi) {
-            while (*hexit && *hexit != ';') {
-              char hc = isalpha(*hexit) ? tolower(*hexit) : *hexit;
-              val *= 16;
-              val += strchr(hex, hc)-hex;
-              hexit++;
-            }
-
-            if (val < 32) {
-              warning(MYNAME ": Ignoring illegal character %s;\n\tConsider emailing %s at <%s>\n\tabout illegal characters in their GPX files.\n", badchar, gpx_author?gpx_author:"(unknown author)", gpx_email?gpx_email:"(unknown email address)");
-              memmove(badchar, semi+1, strlen(semi+1)+1);
-              len -= (semi-badchar)+1;
-              badchar--;
-            }
-          }
-          badchar = strstr(badchar+1, "&#x");
-        }
-      }
       result = XML_Parse(psr, buf, len, done);
     } else if (input_string) {
       done = 0;
index 0a23fbd424b05339db899ce842608590900ccf74..880cd76685499d164bf08884586ba979e28d7962 100644 (file)
@@ -1643,9 +1643,18 @@ typedef enum {
   sl_float,
   sl_double,
 } sl_element;
+
+typedef enum {
+  fld_cadence, 
+  fld_depth, 
+  fld_heartrate, 
+  fld_temperature, 
+  fld_power
+} wp_field;
+
 static void kml_mt_simple_array(const route_head* header,
                                 const char* name,
-                                int offset, sl_element type)
+                                wp_field member, sl_element type)
 {
   queue* elem, *tmp;
   writer.writeStartElement("gx:SimpleArrayData");
@@ -1653,11 +1662,33 @@ static void kml_mt_simple_array(const route_head* header,
 
   QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
 
-    char* datap = (char*) elem + offset;
+    waypoint* wpt = (waypoint *) elem;
+    char *datap;
+     
+
+    switch (member) {
+      case fld_power: 
+        datap = (char *) &wpt->power;
+        break;
+      case fld_cadence: 
+        datap = (char *) &wpt->cadence;
+        break;
+      case fld_depth: 
+        datap = (char *) &wpt->depth;
+        break;
+      case fld_heartrate: 
+        datap = (char *) &wpt->heartrate;
+        break;
+      case fld_temperature: 
+        datap = (char *) &wpt->temperature;
+        break;
+      default:
+        fatal("Bad member type");
+    }
 
     switch (type) {
     case sl_char: {
-      char data = *(char*) datap;
+      signed char data = *(signed char*) datap;
       writer.writeTextElement("gx:value", QString(data));
     }
     break;
@@ -1800,24 +1831,19 @@ static void kml_mt_hdr(const route_head* header)
     writer.writeAttribute("schemaUrl", "#schema");
 
     if (has_cadence)
-      kml_mt_simple_array(header, kmt_cadence,
-                          offsetof(waypoint, cadence), sl_uchar);
+      kml_mt_simple_array(header, kmt_cadence, fld_cadence, sl_uchar);
 
     if (has_depth)
-      kml_mt_simple_array(header, kmt_depth,
-                          offsetof(waypoint, depth), sl_double);
+      kml_mt_simple_array(header, kmt_depth, fld_depth, sl_double);
 
     if (has_heartrate)
-      kml_mt_simple_array(header, kmt_heartrate,
-                          offsetof(waypoint, heartrate), sl_uchar);
+      kml_mt_simple_array(header, kmt_heartrate, fld_heartrate, sl_uchar);
 
     if (has_temperature)
-      kml_mt_simple_array(header, kmt_temperature,
-                          offsetof(waypoint, temperature), sl_float);
+      kml_mt_simple_array(header, kmt_temperature, fld_temperature, sl_float);
 
     if (has_power)
-      kml_mt_simple_array(header, kmt_power,
-                          offsetof(waypoint, power), sl_float);
+      kml_mt_simple_array(header, kmt_power, fld_power, sl_float);
 
     writer.writeEndElement(); // Close SchemaData tag
     writer.writeEndElement(); // Close ExtendedData tag
index 0b6af46f0b0956d928d47d2d3fea9d849bef9a71..657758360639070750a8ae7f96feeac8aaa339ba 100644 (file)
@@ -50,7 +50,7 @@ pdb_invalid_file(const pdbfile *pdb_in, const char *fmt, ...)
 /* try to read to EOF (avoid determining file-size) */
 
 static void *
-pdb_read_tail(gbfile *fin, gbuint32 *size)
+pdb_read_tail(gbfile *fin, gbint32 *size)
 {
   int count;
   char buff[256];
@@ -189,7 +189,7 @@ pdb_load_data(pdbfile *fin)
       fin->appinfo_len = gbfread(fin->appinfo, 1, top - offs, fin->file);
       offs += fin->appinfo_len;
     } else {
-      gbuint32 size;
+      gbint32 size;
       fin->appinfo = pdb_read_tail(fin->file, &size);
       fin->appinfo_len = size;
       offs += size;
index e8a409f802fbeb0100d6c7df7f1a60c346444435..3a08e9885337ea6d22e0c76bd02050bb4e668fb4 100644 (file)
@@ -40,7 +40,7 @@
 
 typedef struct pdbrec_s {
   gbuint32  offs;
-  gbuint32  size;
+  gbint32  size;
   gbuint32 id;
   gbuint8  category;
   gbuint8  flags;
@@ -58,8 +58,8 @@ typedef struct {
   time_t mtime;                /* modification time */
   time_t btime;                /* backup time */
   gbuint32 revision;
-  gbuint32 appinfo_offs;       /* offset to application info */
-  gbuint32 index_offs; /* offset to sort-index info */
+  gbint32 appinfo_offs;        /* offset to application info */
+  gbint32 index_offs;  /* offset to sort-index info */
   gbuint32 creator;
   gbuint32 type;
   gbuint32 uid;
index 81fbda3de407687dca71cabed73e946c9fbb5358..7e9ce1eecbf13563ffc61af03390c59ea81999e3 100644 (file)
@@ -33,7 +33,7 @@ rd_init(const char *fname)
 
 double wppos_to_dec(char *value)
 {
-  if (strstr(value, "°") == NULL) {
+  if (strstr(value, "\xB0") == NULL) {
     return atof(value);
   } else {
     int degrees, minutes;
@@ -47,7 +47,7 @@ double wppos_to_dec(char *value)
       sign = -1;
     }
 
-    sscanf(value, "%d°%d'%f\"", &degrees, &minutes, &seconds);
+    sscanf(value, "%d\xB0%d'%f\"", &degrees, &minutes, &seconds);
     return sign * (degrees + ((float)minutes / 60) + (seconds / 3600));
   }
 }
index afddbc9ded4de384e64b67588aba46ba9c0a5880..465eaa2bcc576793c0f4216c47336d747466a416 100644 (file)
@@ -772,7 +772,7 @@ skytraq_read_single_sector(unsigned int sector, gbuint8 *buf)
   unsigned int c, i, j, cs;
   gbuint8 buffer[16];
 
-  if (sector < 0  ||  sector > 0xFF) {
+  if (sector > 0xFF) {
     fatal(MYNAME ": Invalid sector number (%i)\n", sector);
   }
 
@@ -866,7 +866,7 @@ skytraq_read_multiple_sectors(int first_sector, unsigned int sector_count, gbuin
     fatal(MYNAME ": Invalid sector number (%i)\n", first_sector);
   }
   be_write16(&MSG_LOG_READ_MULTI_SECTORS[1], first_sector);
-  if (sector_count < 0  ||  sector_count > 0xFFFF) {
+  if (sector_count > 0xFFFF) {
     fatal(MYNAME ": Invalid sector count (%i)\n", sector_count);
   }
   be_write16(&MSG_LOG_READ_MULTI_SECTORS[3], sector_count);
index db184a0f169f557d1030f3ee87cfe4af05263c0d..137e5e76a01198879185f752deeb7356363dc7ce 100644 (file)
@@ -384,7 +384,7 @@ routesimple_init(const char *args)
     fatal(MYNAME ": You may specify only one of crosstrack, length, or relative.\n");
   }
   if (!xteopt && !lenopt && !relopt) {
-    xteopt = "";
+    xteopt = (char *) "";
   }
 
   if (countopt) {
index acb3be9555bac13f2208cdacda8e010bd8c82c03..8aed2fce22990aa82e09f38a1d0718cd44f1595c 100644 (file)
@@ -128,7 +128,7 @@ text_disp(const waypoint *wpt)
   if (wpt->altitude != unknown_alt) {
     xasprintf(&altout, " alt:%d", (int)((altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude));
   } else {
-    altout = "";
+    altout = (char *) "";
   }
   xasprintf(&tmpout2, "%s (%d%c %6.0f %7.0f)%s", tmpout1, utmz, utmzc, utme, utmn, altout);
   gbfprintf(file_out, "%-16s  %59s\n",
index 55d30e4db45b0d605c326403923d0113406bbc2e..75ee9a57d60924feb653ee8cb465cef36e909de4 100644 (file)
@@ -1221,7 +1221,7 @@ assign_option(const char *module, arglist_t *ap, const char *val)
 void
 disp_vec_options(const char *vecname, arglist_t *ap)
 {
-  for (ap = ap; ap && ap->argstring; ap++) {
+  for (; ap && ap->argstring; ap++) {
     if (*ap->argval && ap->argval) {
       printf("options: module/option=value: %s/%s=\"%s\"",
              vecname, ap->argstring, *ap->argval);
index 2c47c8b32abfcd7589d569315e9b34df6f8afacf..9c6fd8c2000c0b9d87cc4aca9b9f1714e5d1f73e 100644 (file)
@@ -1,4 +1,4 @@
-char *xhtml_entities =
+const char *xhtml_entities =
   "<!-- Portions (C) International Organization for Standardization 1986\n"
   "     Permission to copy in any form is granted for use with\n"
   "     conforming SGML systems and applications as defined in\n"